#!/usr/bin/perl
#$Id$
# print todos in this format:
# project|due date|description 
# ...so they can be sorted and printed 

use XML::Simple;
use Data::Dumper;

#
# generate hash from stdin
my $tophash = XMLin('-');
#print Dumper($tophash);

if ($tophash =~ /hash/i) {
    &xmlwalk(\%$tophash); 
}

sub xmlwalk {
    my $tophash = $_[0];
    #
    # if the element is "todo", we've found the todo array
    while (my ($element, $value) = each %$tophash ) {
        if ( $element =~ /todo/i ) {
            #print ("$element, $value\n");
            foreach $todo (@$value) {
                print ("| $todo->{due}->{content} ");
                print ("| $todo->{description} | \n");
            }
        }
    }
}
